package com.wn.web;

import com.github.pagehelper.PageInfo;
import com.wn.common.pojo.Rsp;
import com.wn.common.pojo.Traveller;
import com.wn.service.TravellerService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


@RestControllerAdvice
@RequestMapping("traveller")
@Api(value="旅客接口")
public class TravellerController {
    @Autowired
    private TravellerService travellerService ;
    /**
     * 旅客注册接口
     * @param traveller
     * @return
     */
    @PostMapping("register")
     public Rsp TravellerRegister(@RequestBody @Valid Traveller traveller){
       return travellerService.insertTraveller(traveller);
     }

    /**
     * 删除接口
     * @param travellerid
     * @param updateUserId
     * @return
     */
     @DeleteMapping("delete")
    public Rsp DeleteTraveller(int travellerid,int updateUserId){
        return travellerService.deleteTraveller(travellerid,updateUserId);

     }

     @PutMapping("update")
    public Rsp updateTraveller(@RequestBody Traveller traveller){
        return travellerService.updateTraveller(traveller);

     }

    /**
     * 获取旅客列表
     * @param page
     * @param pageSize
     * @return
     */
     @GetMapping("queryList")
    public Rsp queryTravellerList(Integer page,Integer pageSize){
        return travellerService.selectTravellerList(page,pageSize);

     }

    /**
     * 条件查询旅客列表
     * @param page
     * @param pageSize
     * @param traveller
     * @return
     */
    @GetMapping("queryByCondition")
     public Rsp queryTravellerListByCondition(Integer page,Integer pageSize,Traveller traveller){
        return travellerService.selectTravellerListByCondition(page,pageSize,traveller);

     }

    /**
     * 根据主键查询单个用户
     * @param travellerid
     * @return
     */
    @GetMapping("queryByPrimaryKey")
    public Rsp queryTravellerListByPrimaryKey(int travellerid){
       return travellerService.selectTravellerByPrimaryKey(travellerid);

    }
}
